#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define mes(x) memset(x,0,sizeof(x))
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 2e3+10;

ll tot = 0;
struct edge{int u,v,w;}e[MAXN*MAXN];
int fa[MAXN],cnt,n;
bool operator < (edge a,edge b){return a.w < b.w;}

int gf(int x){return fa[x] == x ? x : fa[x] = gf(fa[x]);}

int main (){
	n = in;fa[n+1] = n+1;
	for(int i = 1;i <= n;i++) {
		fa[i] = i;
		for(int j = i;j <= n;j++){
			int w = in;
			e[++cnt] = (edge){i,j+1,w};
		}
	}
	sort(e+1,e+cnt+1);
	for(int i = 1;i <= cnt;i++){
		int x = e[i].u,y = e[i].v,w = e[i].w;
		if(gf(x) != gf(y)){
			tot += w;
			fa[gf(x)] = gf(y);
		}
	}
	printf("%lld\n",tot);
	return 0;
}

